$(function () {
    /*advSearchFun();*/

    function queryUserMemberBuyRecordList(pageNo) {
        var params = $("#search-form").serializeJSON();
        params = JSON.stringify(params);
        var obj = {
            url: baseloaction + '/admin/user/cus/ajaxCusUserMemberRecordList',//请求URL
            contextId:'member-buy-record-list-box',//响应内容页面设置内容ID
            params:params,//请求参数
            pageNo:pageNo,//页码
            pageCall:queryUserMemberBuyRecordList, //分页回调加载数据(点击上下页时调用,该方法也在加载页面完成时调用)
            callback:function () {//数据加载完成回调

            }
        };
        ajaxGetListData(obj)
    }

    queryUserMemberBuyRecordList(1);

    $("body").on('click','#submitFrom',function () {
        queryUserMemberBuyRecordList(1);
    }).on('click','#querySubmit',function () {
        queryUserMemberBuyRecordList(1);
    }).on('click',".member-status-box",function () {
        var _this = $(this);
        var id = _this.data('id');
        var status = _this.data("status");
        var message = '';
        if(status==1){
            message = '确认要恢复该会员开通记录吗？';
        }else if(status==2){
            message = '确认要禁用该会员开通记录吗？';
        }
        icModale(2,message,3,function () {
            $.ajax({
                url:baseloaction +'/admin/user/cus/updateMemberRecordStatus',
                type:'post',
                dataType:'json',
                data:{'id':id,'status':status},
                success:function (result) {
                    if(result.success==true){
                        if(status==1){
                            _this.html('');
                            _this.append('<i class="fa fa-unlock-alt"></i>');
                            _this.data('status',"2");
                            _this.attr('data-original-title',"禁用");
                            $("#member-record-status-"+id).html('<span class="label label-info">正常</span>');
                        }else if(status==2){
                            _this.html('');
                            _this.append('<i class="fa fa-history"></i>');
                            _this.data('status',"1");
                            _this.attr('data-original-title',"恢复");
                            $("#member-record-status-"+id).html('<span class="label label-danger">禁用</span>');
                        }
                    }else{
                        icModale(0,result.message);
                    }
                },
                error:function (error) {
                    icModale(0,'系统错误，操作失败');
                }
            });
        });
    });
});